package com.rocksdata.mc.ui.activity;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.View;

import com.ctz.commonframe.ui.TitleBarActivity;
import com.ctz.commonframe.ui.view.NoScrollViewPager;
import com.ctz.commonframe.ui.widget.ViewPagerFragmentAdapter;
import com.rocksdata.mc.R;
import com.rocksdata.mc.ui.fragment.TreatedOAFragment;
import com.rocksdata.mc.ui.fragment.UntreatedOAFragment;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.Event;
import org.xutils.view.annotation.ViewInject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 陈堂正 on 2017/5/18.
 */
@ContentView(R.layout.activity_oa_treat)
public class OATreatActivity extends TitleBarActivity {
    @ViewInject(R.id.view_flag1)
    private View flag1;
    @ViewInject(R.id.view_flag2)
    private View flag2;
    @ViewInject(R.id.vp_oa_treat)
    private NoScrollViewPager vpOATreat;
    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setTitleMiddleText("待办已办");

        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(new UntreatedOAFragment());
        fragmentList.add(new TreatedOAFragment());

        vpOATreat.setAdapter(new ViewPagerFragmentAdapter(getSupportFragmentManager(), fragmentList));
        flag1.setVisibility(View.VISIBLE);
        flag2.setVisibility(View.GONE);
        vpOATreat.setCurrentItem(0);
    }

    @Event(value = {R.id.layout_oa_tab1, R.id.layout_oa_tab2})
    private void onClick(View view){
        switch (view.getId()) {
            case R.id.layout_oa_tab1:
                flag1.setVisibility(View.VISIBLE);
                flag2.setVisibility(View.GONE);
                vpOATreat.setCurrentItem(0);
                break;
            case R.id.layout_oa_tab2:
                flag2.setVisibility(View.VISIBLE);
                flag1.setVisibility(View.GONE);
                vpOATreat.setCurrentItem(1);
                break;
        }
    }
}
